﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ApplicationLibrary.DBManager;
using System.ComponentModel;

namespace ApplicationLibrary.ExtendedControls
{
    public class ExToolStrip : ToolStrip
    {
        [Description("X position for Checked flag"), Category("Appearance")] 
        public int XCheckPosition { get; set; }
        [Description("Y position for Checked flag"), Category("Appearance")] 
        public int YCheckPosition { get; set; }

        public ExToolStrip() : base()
        {
            ThemeManager.SetTheme(this);
            Renderer = new ABRender();
        }
    }

    internal class ABRender : ToolStripProfessionalRenderer
    {
        protected override void OnRenderItemImage(ToolStripItemImageRenderEventArgs e)
        {
            base.OnRenderItemImage(e);
            var btn = e.Item as ToolStripButton;
            if (btn != null && btn.CheckOnClick && btn.Checked)
            {
                ExToolStrip ts = btn.GetCurrentParent() as ExToolStrip;
                e.Graphics.DrawImage(Properties.Resources.Check, ts.XCheckPosition, ts.YCheckPosition);
            }
        }
    }
}
